package cn.lastcrdg.testlrslide;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * author：liluo
 * e-mail：lastcrazysun@163.com
 * company：cusc
 * date：2017/12/12 14:22
 * description：
 */

public class MyAdaptercopy extends RecyclerView.Adapter<MyAdaptercopy.MyViewHolder> {
    public static final String TAG = MyAdaptercopy.class.getSimpleName();

    Context mContext;
    private boolean isOpenEdit = false;

    private List<Bean> mDatas = new ArrayList<>();

    public void setDatas(List<Bean> datas) {
        mDatas = datas;
        notifyDataSetChanged();
    }

    public MyAdaptercopy(Context context, ArrayList<Bean> date) {
        mContext = context;
        this.mDatas = date;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.layout_slide_item_copy, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {

        holder.textView.setText(mDatas.get(position).getText());
        //设置内容布局的宽为屏幕宽度
        holder.slideLayout.openEdit(mDatas.get(position).isOpen());
    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {

        private TextView textView;
        private RelativeLayout mLlContent;
        private RelativeLayout mRlChose;
        private MiniSlideRightLayout slideLayout;

        MyViewHolder(View view) {
            super(view);
            slideLayout = (MiniSlideRightLayout) view;
            textView = view.findViewById(R.id.tv_content);
            mLlContent = view.findViewById(R.id.rl_content);
            mRlChose = view.findViewById(R.id.rl_chose);
        }
    }
}
